package com.yjd.comm.user.convert;

import java.util.Collection;
import java.util.List;

import com.yjd.comm.enums.SexEnum;
import com.yjd.comm.user.model.UserIdcardModel;
import com.yjd.comm.util.DateUtil;
import com.yjd.comm.util.FrameUtil;

/**
 * <b>description</b>：用户认证信息 <br>
 * <b>time</b>：2015-1-4下午8:31:17 <br>
 * <b>author</b>： ready likun_557@163.com
 */
public class UserIdCardModelConvert {
	public static UserIdcardModel convert(UserIdcardModel model) throws Exception {
		if (model != null) {
			model.getStrMap().put("birthday",
					FrameUtil.formatBirth(model.getBirthday()));

			model.getStrMap()
					.put("age",
							model.getBirthday() != null
									&& model.getBirthday() != 0 ? DateUtil
									.getAge(DateUtil.parseDate(
											model.getBirthday() + "",
											DateUtil.PATTERN_yyyyMMdd)) : "");
			model.getStrMap().put("sex", SexEnum.getDesc(model.getSex()));
		}
		return model;
	}

	public static Collection<UserIdcardModel> convert(Collection<UserIdcardModel> models)
			throws Exception {
		if (models == null || models.size() == 0) {
			return models;
		}
		for (UserIdcardModel model : models) {
			convert(model);
		}
		return models;
	}
	
	
}
